<?php
class info_pengeluaran extends MY_Controller{
    var $data,
        $limit = 10;
    function info_pengeluaran(){
        parent::MY_Controller();
        $this->data['title'] = 'Informasi Pengeluaran';
        $this->load->model('m_pengeluaran');
    }
    function index(){
        $this->get_pengeluaran('all',0);
    }
    function search(){
        $url = $this->input->post("url");
        $params = "awal_".date2mysql($this->input->post("awal"));
        $params .= "__akhir_".date2mysql($this->input->post("akhir"));
        redirect("$url/$params/0/");
    }
    function get_pengeluaran($params = 'all',$offset = 0){
        $option = parsing_param2($params);
        $this->data['content'] = 'pengeluaran/info_pengeluaran';
        $this->data['formTitle'] = 'Parameter Pencarian';
        $this->data['searchLink'] = 'info_pengeluaran/get_pengeluaran';
        $uri_segment = 4;
        if($offset != 0){
          $offset = $this->uri->segment($uri_segment);  
        }
        $num_rows = $this->m_pengeluaran->getCountRows($option);
        $this->data['listPengeluaran'] = $this->m_pengeluaran->getListPengeluaran($offset,$this->limit,$option);
        $config['base_url'] = site_url('info_pengeluaran/get_pengeluaran').'/'.$params;
        $config['uri_segment'] = $uri_segment;
        $config['total_rows'] = $num_rows;
        $config['per_page'] = $this->limit;
        $this->pagination->initialize($config);
        $this->data['pagination'] = $this->pagination->create_links();
        $this->data['offset'] = $offset;
        
        $this->render($this->data);
    }
    function print_pengeluaran($params){
        $option = parsing_param2($params);
        $data['listPengeluaran'] = $this->m_pengeluaran->getListPengeluaran(NULL,NULL,$option);
        
        $this->load->view('pengeluaran/cetak_pengeluaran',$data);
    }
    function export_data($params){
        $option = parsing_param2($params);
        $data['data'] = $this->m_pengeluaran->getListPengeluaran(NULL,NULL,$option);
        $data['params'] = $option;
        $this->load->view('pengeluaran/cetak_excel',$data);
    }
}
?>
